/***************************************************************
*  Copyright (c) 2007 by GroupMe! Team (www.groupme.net)
*  All rights reserved.
*
*  This file is part of the GroupMe! Project. Source code of 
*  this project is closed and redistribution of this code is
*  prohibited. 
*  
*  Contact: http://www.groupme.net
*
*  This copyright notice MUST APPEAR in all copies of the file!
***************************************************************/
package net.groupme.utils;

import java.net.MalformedURLException;
import java.net.URL;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import net.groupme.gui.constants.VIEW_VOCABULARY;

/**
 * created on Oct 11, 2007
 * 
 * This class provides some static utility method that compute URLs for 
 * given group IDs, ...
 * 
 * @author Fabian Abel, <a href="mailto:abel@l3s.de">abel@l3s.de</a>
 * @author last edited by: $Author: fabian $
 * 
 * @version $Revision: 1.3 $ $Date: 2007-10-25 15:29:45 $
 */
public class URLResolver {
	
	/** Logger for this class  */
	protected static final Log logger = LogFactory.getLog(URLResolver.class);

	/**
	 * Returns the absolute Web URL of a Group. For example:
	 * <pre>http://groupme.org/GroupMe/browse-groups.do?id=480</pre>
	 * 
	 * @param id the id of the group
	 * @return Web URL of a Group
	 */
	public static final URL getGroupURL(String id){
		try {
			return new URL(VIEW_VOCABULARY.RESTful_GROUP_URI_PATTERN + id);
		} catch (MalformedURLException e) {
			logger.error("Mailformed Group-URL", e);
			return null;
		}
	}
	
	/**
	 * Returns the absolute Web URL for search operations, e.g.:
	 * <pre>http://groupme.org/GroupMe/search.do</pre>
	 * 
	 * @param id the id of the group
	 * @return Web URL of a Group
	 */
	public static final String getGroupMeSearchURL(){
		return VIEW_VOCABULARY.GROUPME_BASE_URL + VIEW_VOCABULARY.ACTION_SEARCH;
	}
}
